package org.teamh.connection.json.handler;

import org.teamh.connection.json.event.JsonEventObject;
import org.teamh.game.Start;
import org.teamh.logic.datamodel.*;

public class MessageHandler extends JsonMasterHandler {

	public MessageHandler(Start start, DatamodelManager manager) {
		super(start, manager);
	}
	
	public boolean handleMsg(JsonEventObject json) {
		
		if (json.getSource().startsWith("Message")) {
			if (json.getProperty().equals("text")) {
				if (json.getNewValue().contains("ignoring")) {
//					JsonSender send = new JsonSender(start);
//					Tile tile = null;
//					for (String id : manager.getTiles().keySet()) {
//						tile = manager.getTile(id);
//					}
//					send.chooseTile(tile.getID());
//					send.chatWithAll("######################test###################");
//					send.startGame();
				}
				return true;
			}  else if (json.getProperty().equals("type")) {
				//handle errors
				//TODO
				return true;
			}
			return false;
		} else {
			return false;
		}	
	}
}